|
|
|
|
|
|
|
Because you already have the completed graph library, you can complete your assignment with as few as 10 lines of Visual Basic code. |
|
|
|
|
|
|
|
|
First, if you don't have it running right now, start Visual Basic and create a new Standard EXE project. If you still have Visual Basic up from the last section of this chapter, select File | Add Project . . . to add a new Standard EXE project. Make this new project the Default startup project, too. |
|
|
|
|
|
|
|
|
Now, select Project | References and locate and select the prjDataGraph library. This links your new project with the OLE Server DLL that you built earlier in this chapter. |
|
|
|
|
|
|
|
|
Add a single button to a blank form. Set its Name property to cmdRepSales and its Caption property to &RepSales. Add the code from Listing 11.20 to support the button. |
|
|
|
|
|
|
|
|
Listing 11.20. Adding code to the cmdRepSales_Click event. |
|
|
|
|
|
|
|
|
Private Sub cmdRepSales_Click()
'
' test graph libaray
'
Dim objDG As Object
'
Set objDG = New DataGraph
'
objDG.DatabaseName = App.Path & "\..\..\data\books5.mdb"
objDG.sqlselect = "SELECT SalesRep, SUM(Units) AS UnitsSold FROM BookSales
GROUP BY SalesRep"
objDG.graphfield = "UnitsSold"
objDG.graphTitle = "Units Sold by Sales Rep"
'
objDG.showgraph
'
End Sub |
|
|
|
|
|
|
|
|
This code example sets a few properties and then calls the ShowGraph method. That's all there is to it! Save this form as FRMTEST.FRM and the project as PRJTEST.VBP. Now run the project. After you click the single command button, you see the graph displayed on-screen. Your screen should look something like the one shown in Figure 11.11. |
|
|
|
|
|
|
|
|
You have just completed your first database graphing project using the new OLE Server! Before you end your work on this OLE Server, let's add a few new properties to the class object. These give you (and our users) greater control over the graph display. |
|
|
|
|
|